package com.example.demo.entity;

import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;

/**
 * 供应商实体
 */
@Data
@Entity
@Table(name = "suppliers")
@EqualsAndHashCode(callSuper = true)
public class Supplier extends BaseEntity {
    
    @Column(name = "supplier_code", unique = true, nullable = false, length = 50)
    private String supplierCode;
    
    @Column(name = "supplier_name", nullable = false, length = 100)
    private String supplierName;
    
    @Column(name = "contact_person", length = 50)
    private String contactPerson;
    
    @Column(name = "contact_phone", length = 20)
    private String contactPhone;
    
    @Column(name = "contact_email", length = 100)
    private String contactEmail;
    
    @Column(name = "address", length = 200)
    private String address;
    
    @Column(name = "bank_account", length = 50)
    private String bankAccount;
    
    @Column(name = "bank_name", length = 100)
    private String bankName;
    
    @Column(name = "tax_number", length = 50)
    private String taxNumber;
    
    @Enumerated(EnumType.STRING)
    @Column(name = "status", nullable = false)
    private SupplierStatus status = SupplierStatus.ACTIVE;
    
    @Column(name = "credit_rating", length = 10)
    private String creditRating;
    
    @Column(name = "payment_terms", length = 100)
    private String paymentTerms;
    
    /**
     * 供应商状态枚举
     */
    public enum SupplierStatus {
        ACTIVE("启用"),
        INACTIVE("停用"),
        BLACKLIST("黑名单");
        
        private final String description;
        
        SupplierStatus(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
}
